import sqlite3

# TODO: 数据库操作

def init_user(database):
    # 连接到SQLite数据库（如果数据库不存在，将创建一个新的数据库文件）
    with sqlite3.connect(database) as conn:
        # 创建一个游标对象
        cursor = conn.cursor()
        cursor.execute('''
        CREATE TABLE users (
            id INTEGER PRIMARY KEY,
            name TEXT NOT NULL,
            gender TEXT NOT NULL,
            age INTEGER NOT NULL,
            location TEXT
        )
        ''')
    conn.commit()
    conn.close()

def insert_user(database, name, age, location):
    with sqlite3.connect(database) as conn:
        cursor = conn.cursor()
        cursor.execute('''
        INSERT INTO users (name, gender, age, location)
        VALUES (?, ?, ?, ?)
        ''', (name, age, location))
    conn.commit()
    conn.close()